package de.androidschoice.androids.choice;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import de.androidschoice.androids.choice.interfaces.Game;
import de.androidschoice.androids.choice.interfaces.GameScene;
import de.androidschoice.androids.choice.xml.Xml2GameParser;
import android.app.Application;

public class ChoiceApplication extends Application {
	private Game acg;
	private int android;
	private String acgPath;
	
	@Override
	public void onCreate() {
		// TODO Auto-generated method stub
		super.onCreate();
	}

	public void setAndroidsChoiceGame(Game acg) {
		this.acg = acg;
	}
	
	public void setACGPath(String acgPath) {
		this.acgPath = acgPath;
	}
	
	public void loadACG() throws IOException, ParserConfigurationException, SAXException {
		this.setAndroidsChoiceGame(Xml2GameParser.getInstance().parseAndroidsChoiceGameFromXML(this.acgPath));
	}

	public String getGameTitle() {
		return acg.getGameTitle();
	}
	
	public GameScene getScene(Integer number) {
		if (number == null) {
			return acg.getScene(Integer.valueOf(1));
		} else {
			return acg.getScene(number);
		}
	}
	
	public void saveChosenAndroid(int android) {
		this.android = android;
	}
	
	public String getAndroidPostfix() {
		return String.valueOf(this.android);
	}
}